﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyWeb.Business;
using MyWeb.Data;
using MyWeb.Common;
using System.Data;

namespace MobileRecharge
{
    public partial class UserInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Session["folder"] = "UserInfo";
                BindGrid();
            }
        }
        private void BindGrid()
        {
            tb_UserInfo data = new tb_UserInfo();
            data.Username = Session["Username"].ToString();
            DataTable Dtable= tb_UserService.tb_User_GetById(data);
            txtPassWord.Text = Dtable.Rows[0]["PassWord"].ToString();
            txtPhone.Text = Dtable.Rows[0]["Phone"].ToString();
            txtUserName.Text = Dtable.Rows[0]["UserName"].ToString();
            txtAddress.Text = Dtable.Rows[0]["Address"].ToString();

            if(Dtable.Rows[0]["Gender"].ToString()=="True"){
            ckbGender.Checked=true;
            }else{
            ckbGender.Checked=false;
            }
            if (Dtable.Rows[0]["Status"].ToString() == "True")
            {
                ckbStatus.Checked = true;
            }else{
                ckbStatus.Checked = false;
            }
             
        }

        protected void btnEdit_Click(object sender, EventArgs e)
        {
            String status = "False", gender = "False";
            if (ckbStatus.Checked)
            {
                status = "True";
            }
            if (ckbGender.Checked)
            {
                gender = "True";
            }
            tb_UserInfo data = new tb_UserInfo();
            data.Username = txtUserName.Text;
            data.Address = txtAddress.Text;
            data.Phone = txtPhone.Text;
            data.Password = txtPassWord.Text;
            data.Status = status;
            data.Gender = gender;
            tb_UserService.tb_User_Update(data);
            Response.Redirect("Recharge.aspx");
        }
    }
}